<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        canvas{
            width: 500px;
            height: 500px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
    <canvas class="canvas"></canvas>
    <script>
         let canvas = document.querySelector(".canvas");
         let ctx = canvas.getContext("2d");
        
        let obj = {
            key1:"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1114%2F113020142315%2F201130142315-1-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1655879414&t=45863470c303c27709b38fcb3c1f317a",
            key2:"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp09%2F21061109241GT3-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1655879414&t=b9ba18c61c42306fefaf647b0cf8cfb1",
            key3:"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp09%2F210F2130512J47-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1655879414&t=9b9aac8f1bdc2c0e43840921b5d2d9d7"
        }
       
       function cb(arr,call){
        let length=0;
        let num = 0;
        let imgsa={}
        for(let key in arr){
            length++
        }

        
        for(let key in arr){
            let imgs = new Image();
            imgs.src = arr[key];
            imgs.onload=function(){
                num++
                imgsa[key]=this
                if(num == length){
                    call(imgsa)
                    // console.log(imgs);
                }
            }
        }
    }

    cb(obj,function(imgsa){
       // console.log(imgs);
       console.log(imgsa);
        ctx.drawImage(imgsa.key3,0,0)
    })
    </script>
</body>
</html>